package com.ofek.applicationbase.broadcast;

import java.util.ArrayList;

public class DelegateBroadcaster<T> {
	protected final ArrayList<Delegate<T>> listeners = new ArrayList<Delegate<T>>();
	public boolean register(final Delegate<T> listener) {
		if (listeners.contains(listener)) return false;
		return listeners.add(listener);
	}
	public boolean unregister(final Delegate<T> listener) {
		return listeners.remove(listener);
	}
	public void broadcast(final T t) {
		for (final Delegate<T> l : listeners) 
			l.invoke(t);
	}
}
